﻿@model Kooboo.CMS.Web.Areas.Sites.Models.CreateSiteModel
@using Kooboo.Web.Script.Serialization
@{
    ViewBag.Title = "New site".Localize();
    Layout = "~/Views/Shared/Blank.cshtml";
    var guid = Guid.NewGuid();
}
@section Panel{
    <ul class="panel">
        <li>
            <a data-ajaxform="">
                @Html.IconImage("save") @("Save".Localize())</a>
        </li>
        @foreach (var group in Kooboo.CMS.Sites.Extension.UI.TopToolbar.ToolbarButtons.GetToolbarButtons(ViewContext.RequestContext))
        {
            @Html.Partial("_ToolbarGroupButtons", group)
        }
        <li>
            <a href="@ViewContext.RequestContext.GetRequestValue("return")">
                @Html.IconImage("cancel") @("Back".Localize())</a>
        </li>
    </ul>
}
<div class="block common-form">
    <h1 class="title">@ViewBag.Title</h1>
    @using (Html.BeginForm())
    { 
        <input type="hidden" value="" name="Parent" />
        <table>
            <tbody>
                <tr>
                    <th>@("Template".Localize()) (<a target="_blank" href="@Url.Action("Index", "SiteTemplate", ViewContext.RequestContext.AllRouteValues())">@Html.Raw("Manage".Localize())</a>)
                    </th>
                    <td>
                        <ul class="site-list">
                            @{
        var i = 0;
                            }
                            @foreach (var item in ServiceFactory.SiteTemplateManager.All())
                            {
                                i++;
                                <li @if (i > 4)
                                    {@("class=hide")}>
                                    <span>
                                        <input type="radio" name="template" value="@item.TemplateName" id="@item.TemplateName"  @Validator.Required().ClientValidationRule.GenerateHtmlAttributes()/>
                                        <label for="@item.TemplateName"></label>
                                        <img src="@Url.Content(string.IsNullOrEmpty(item.Thumbnail) ? "~/Images/Default.png" : item.Thumbnail)" />
                                    </span>
                                    <label class="name" for="@item.TemplateName">@item.TemplateName</label>
                                </li>
                            }
                            @if (i > 4)
                            {
                                <li class="extend"><a>@Html.IconImage("arrow")</a></li>
                            }
                        </ul>
                        @Html.ValidationMessageForInput("template")
                    </td>
                </tr>
                @Html.EditorFor(m => m.Name, new { HtmlAttributes = new { @class = "medium" } })
                @Html.EditorFor(m => m.Repository, new { HtmlAttributes = new { @class = "medium" } })
                @Html.EditorFor(m => m.Membership, new { HtmlAttributes = new { @class = "medium" } })
                @Html.EditorFor(m => m.Culture, new { HtmlAttributes = new { @class = "medium" } })
                @Html.EditorFor(m => m.TimeZoneId, new { HtmlAttributes = new { @class = "medium" } })
            </tbody>
        </table>       
    }
</div>
<script>
    $(function () {
        var $siteList = $('.site-list');
        var $extend = $siteList.find('.extend a');
        $extend.click(function () {
            var $self = $(this);
            $self.parent().toggleClass('active');
            $siteList.find('li.hide').toggle('');
        });
    });
</script>
